POV-Ray : Newsgroups : povray.general : recursively defined objects and memory : Re: recursively defined objects and memory Server Time
29 Jul 2024 02:32:42 EDT (-0400)
  Re: recursively defined objects and memory  
From: Anthony D  Baye
Date: 13 Aug 2013 18:45:01
Message: <web.520ab4ece896405b328783aa0@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> Over the weekend, I was trying to implement a CSG method for generating random
> planets.

......

> The rotation transform would be done on the boxFN(...) function in the half
> object, and each iteration would redefine baseFn(...)
>
> scaling each half would then be no trouble with variable substitution.
>
> The only way I've come up with to solve the rotation problem is a separate
> transformation (using a separate angle variable) for each axis.  It would be
> messy, but it could work.

It would help, of course, if POV allowed redefinition of functions...

This is where I am now:

#declare baseFn = function(x,y,z,r) { sqrt(x*x + y*y + z*z) - r }
#declare boxFN = function { y * sqrt(x*x + z*z) }
#declare half = function(x,y,z,P,T) { max(baseFn(x,y,z,3),
boxFN(
    (x*cos(radians(-T))-z*sin(radians(-T)))*cos(radians(-P))+y*sin(radians(-P)),
   -(x*cos(radians(-T))-z*sin(radians(-T)))*sin(radians(-P))+y*cos(radians(-P)),
                    x*sin(radians(-T)) + z*cos(radians(-T))
                    )) }

#for(I,0,1000,1)
    #local PHI = Rand_Normal(0.0, 0.33, RdmA)*360;
    #local THETA = Rand_Normal(0.0, 0.33, RdmB)*360;
    #local s1 = 1 + Rand_Normal(0.0, 0.33, RdmB)*0.025;
    #local s2 = 1 - Rand_Normal(0.0, 0.33, RdmB)*0.025;
    #local newFn = function {
min(half(x/s1,-y/s1,z/s1,-PHI,THETA),half(x/s2,y/s2,z/s2,PHI,THETA)) }
    #undef baseFn
    #declare baseFn = newFn;
    #undef newFn
#end

isosurface {
    function { baseFn(x,y,z) }
    threshold 0
    max_gradient 5
    contained_by{ box {-5, 5} }
        pigment { White }
    }

but it seems that functions are not evaluated as I thought they were.  All it
renders is some permutation of the first iteration. (A sphere, split in half,
both halves scaled independently.)

I was really hoping this would work. Again, if anyone has suggestions, I'd
welcome them.

Regards,
A.D.B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.